/**
 * 加密
 */
"use strict";



const crypto = require('crypto');

/*
    加密
*/
const setCrypto =  (password) => {
    return cryptoFun(password);
}

/*
    解密
*/
const getCrypto =  (newPassword,oldPassword) => {
    const newPas = cryptoFun(newPassword);
    if (newPas === oldPassword) return true;
    else return false
}

function cryptoFun (password) {
    let md5 = crypto.createHash("md5");
    let newPas = md5.update(password).digest("hex");
    return newPas
}

module.exports = {
    setCrypto: setCrypto,
    getCrypto: getCrypto
}